<?php

/*
	info: 我的相关操作
	date: 2011-01-16
*/

if (!defined('ADMIN_WEBINROOT'))
{
	header("HTTP/1.0 404 Not Found");
	exit();
}

$webglobal['file_my'] = array();

//修改密码
if ($webglobal['mode']=='myinfo')
{
	if (global_CheckSubmit('mysubmit'))
	{
		if (empty($webrequest['passwordold']) || admin_EncodePassword($webrequest['passwordold'])!=$user['adminpassword'])
		{
			admin_ShowMessage('请输入正确的当前密码！', '', 'BACK');
		}
		elseif (empty($webrequest['passwordnew']) || !global_CheckPassword($webrequest['passwordnew']))
		{
			admin_ShowMessage('新的密码不符合系统要求。', '', 'BACK');
		}
		elseif (empty($webrequest['passwordtwo']) || $webrequest['passwordtwo']!=$webrequest['passwordnew'])
		{
			admin_ShowMessage('新的密码两次输入不一致。', '', 'BACK');
		}
		else
		{
			admin_CheckFromForm(ADMIN_WEBURLPATH.'/index.php?mode=myinfo');
			$tempnewpassencode = admin_EncodePassword($webrequest['passwordnew']);
			$db->Query("UPDATE {$webconfig['dbpre']}admin_user SET password ='{$tempnewpassencode}' WHERE id='{$user['adminuid']}'");
			global_SetCookie($webglobal['admincookie'], global_EncryptKey($user['adminuid']."\t".$user['adminusername']."\t".$tempnewpassencode, ADMIN_WEBAUTHKEY));

			admin_AddLog("修改个人信息|uid: {$user['adminuid']}, username: {$user['adminusername']}");
			admin_ShowMessage('您的个人信息已经更新成功。', ADMIN_WEBURLPATH.'/index.php?mode=myinfo');
		}
	}
	else
	{
		admin_StartFromForm();
	}
}

template_Display('my', 1);

?>